package com.key.win.system.model;

import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;
import com.key.win.base.model.MybatisID;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;

import java.util.ArrayList;
import java.util.List;
import java.util.Set;

@ApiModel("机构实体")
@Data
@TableName("sys_organ")
@EqualsAndHashCode(callSuper = true)
public class SysOrgan extends MybatisID {
    @ApiModelProperty("code")
    private String code;
    @ApiModelProperty("名称")
    private String name;
    @ApiModelProperty("父节点Id")
    private String parentId;
    @ApiModelProperty("排序")
    private int sort;
    @ApiModelProperty("用户Id")
    @TableField(exist = false)
    private String userId;
    @ApiModelProperty("用户列表")
    @TableField(exist = false)
    private List<SysUser> sysUsers;
    @ApiModelProperty("设备Id")
    @TableField(exist = false)
    private String deviceId;
    @ApiModelProperty("设备列表")
    @TableField(exist = false)
    private List<SysDevice> sysDevices;
    @ApiModelProperty("孩子节点")
    @TableField(exist = false)
    private List<SysOrgan> subOrgan = new ArrayList<>();
    @ApiModelProperty("用户Id集合")
    @TableField(exist = false)
    private Set<String> userIds;
    @ApiModelProperty("用户Id集合")
    @TableField(exist = false)
    private List<SysOrganUser> organUsers;

    @ApiModelProperty("对当前节点是否有管理权限")
    @TableField(exist = false)
    private Boolean administrativePermissions;

    public void addSubSysOrgan(SysOrgan sysOrgan) {
        this.subOrgan.add(sysOrgan);
    }
}
